package com.cdc.servlet_db;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletDb extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1310915855147221532L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sql;
        sql = "SELECT *  FROM vendors";
        DbTool dbTool=new DbTool(getServletContext());
        Statement stmt=dbTool.getStatement();
        try {
			ResultSet rs = stmt.executeQuery(sql);
			int row=rs.getRow();
			System.out.println(row+"");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			doGet(request, response);
		
	}

}
